package com.imooc.sell.controller;

import java.time.LocalDateTime;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GreetingController {

//    @RequestMapping("/greeting" )
//    @RequestMapping(value = "greeting", method = RequestMethod.GET)
    @GetMapping(value="greeting")
    public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) {
        model.addAttribute("name", name);
        System.out.println("----------接收到的name=" + name);
        System.out.println("----------进入greet controller.....now time="+LocalDateTime.now().toLocalTime());
        return "greeting";
    }

}
